﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TCEasyPrintRev.Models;

namespace TCEasyPrintRev.Controllers
{ 
    public class PaketController 
    {
        

        public static void insert(Paket x)
        {
            CRUD<Paket>.insert(x);
        }

        public static void update(Paket x)
        {
            CRUD<Paket>.update(x);
        }

        public static void delete(Paket x)
        {
            CRUD<Paket>.delete(x);
        }



        public static Paket getPaketByID(string id)
        {
            using (var session = CRUD<Paket>.load().OpenSession())
            {
                return session.QueryOver<Paket>().List().Where(x => x.ID == id).Last();

            }
        }

        public  static List<string> getList(string id)
        {
            using (var session = CRUD<Paket>.load().OpenSession())
            {
                return session.QueryOver<Paket>().List().
                    Where(x => x.produk.ID == id).Select(x => x.ID.ToString()+" | "+x.nama ).ToList();

            }
        }

        

        public static void insert(WCF_File.PaketS file)
        {
            CRUD<Paket>.insert(new Paket(file));
        }
    }
}